<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>(健康、注意事项)方案</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">		
		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="css/mui.picker.min.css" />
		<link rel="stylesheet" href="css/grandeHealth.css">
		<style>
			#submit	{
			    width: 95%;padding: 10px 0;margin: 0 auto;position: fixed;bottom: 20px;left: 2.5%;border: none;}
			textarea{height: 400px;}
			.cudisable{background: #ccc;}
			.mui-popup-button.mui-popup-button-bold{font-weight: normal;}
		</style>
	</head>

	<body>
		<!--<header>class="mui-bar mui-bar-nav" style="display: block;height: 64px;padding-top:20px">-->
      		<!--<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>-->
      		<!--<button id="selectTem" style="float: right;">选择模板</button>-->
	    <!--</header>-->
		
		<div class="mui-content">
	 		<textarea name="" rows="" maxlength="510" placeholder="请输入健康方案内容" onkeyup="this.value=this.value.replace(/[, ]/g,'')" cols=""></textarea>
	 		<button type="button" disabled="disabled" id="submit" class="cudisable mui-btn mui-btn-primary mui-btn-block">保存</button>
		</div>

		<script src="js/jquery-1.7.2.min.js"></script>
		<script src="js/mui.min.js"></script>
		<script src="js/grandeHealth.js"></script>
		<!--公共js-->
		<script src="js/medicalRecord.js"></script>
		<script language="JavaScript" type="text/javascript">
			
			function cudisable(_isNo){
				
				if(_isNo != ''){
					
					$('#submit').attr("disabled",null).removeClass('cudisable');
				}else{
					$('#submit').attr("disabled",true).addClass('cudisable');
				}
			}
			
			/*取数据*/
			_typePd(type);
			$("textarea").val(cont);
			
			/*不为空*/
			if($("textarea").val() != ''){
				cudisable($("textarea").val());
			}
            
			/*内容空否，控制按钮高亮*/
            $("textarea").keyup(function(){
            	
		        if($(this).val() == ""){
		        	
		            cudisable($(this).val());
		            
		            /*若cont不为空，按钮可保存*/
		            if(cont != ''){
						cudisable(cont);
					}

		        }else{
		            cudisable($(this).val());
		        }
		    })
            
            /*内容不为空，返回确认*/
            mui.back = function(){
				
				if($("textarea").val() != ''){
					
					var btnArray = ['继续编辑','退出'];
					mui.confirm('退出将不保存修改的内容，退出本次编辑吗？', '提示', btnArray, function(e) {
						if (e.index == 1) {
							
							location.href = "newRecord.html";
						}
					})
					
				}else{
					location.href = "newRecord.html";
				}
	      	}
            
            function _typePd(type){
				
				if(type == '001001'){
					$("textarea").attr('placeholder','请输入健康方案内容')
				}else if(type == '001002'){
					$("textarea").attr('placeholder','请输入注意事项内容')
				}
			}
            
            /*
			 *保存
			 */
			mui("body").on("tap", "#submit", function() {
				
				if(type == '001001'){
					window.localStorage.setItem('headlthPlan',$("textarea").val());
				}else if(type == '001002'){
					window.localStorage.setItem('zhyNotes',$("textarea").val());
				}
				$("textarea").val('');
				//window.android.finish();
				location.href = "newRecord.html?type=" + type;//返回上一页
			})
			
			/*
			 *选择模板
			 */
			mui("body").on("tap", "#selectTem", function() {
				
				showpage('healthProgramN.html?type=' + type);
				//返回上一页
			})
			
		</script> 
	</body>
</html>


